/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package domain;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 *
 * @author David
 */
class LayerMapper {
    
    public static LayerDTO getLayerDTO(Layer layer){
        LayerDTO dto = new LayerDTO();
        
        dto.setName(layer.getName());
        dto.setNumber(layer.getNumber());
        
        Set<UnitDTO> units = new HashSet<UnitDTO>();
        
        for(Unit unit : layer.getUnits()){
            units.add(UnitMapper.getUnitDTO(unit));
        }
        
        Map<String, LayerDTO> allowedLayers = new HashMap<String, LayerDTO>();
        for(Layer layerObject : layer.getAllowedLayers().values()){
            allowedLayers.put(layerObject.getName(), LayerMapper.getLayerDTO(layerObject));
        }
        
        dto.setLayers(allowedLayers);
        dto.setUnits(units);
        
        return dto;
    }
    
}
